The invention relates to a method and an apparatus for modeling the specular reflection of light from a surface.
Computer generated images are created from models of objects. It is desirable that the object depicted in a computer generated image resemble the real object to the maximum extent possible. In some instances, the real object specularly reflects light. That is, when viewed at one or more angles, the object reflects light directly from a light source to the viewer. This specularly reflected light appears as a shiny area on the surface of the object.
As an example, when light is projected onto the outer waxy surface of an apple, at one or more angles the light is directly reflected from a source to the viewer and appears as a shiny spot on the apple. In order to graphically portray the image of an apple, it is desirable to display the xe2x80x9cshiny spotxe2x80x9d on the image of the apple which one would see if viewing the apple in real life.
One method for modeling the specular reflection associated with an object is to utilize a modified version of Gouraud shading. This method will be described with reference to FIG. 1.
First, the surface to be imaged is divided into a number of polygons, such as triangles, the polygons having common vertices. Vectors normal to the surface N1, N2, N3 are calculated at each vertex V1, V2, V3. Using these normal vectors, the light intensity I1, I2, I3 at each vertex V1, V2, V3 is calculated with a light intensity equation. One such equation which accounts for the light intensity from ambient, diffuse and specular components is the equation I=Ia*ka+Ii*[kd(Lxc2x7N)+ks(Rxc2x7V)n].
In this equation, Ia*ka represents the ambient light intensity component and kd(Lxc2x7N) is the diffuse light intensity component. These components, while not necessary to the calculation of the specularly reflected light component, are instrumental in generating an image which accounts for light which impinges on the object from a variety of sources (the ambient component) and the light which impinges on the object from a particular source and is diffusely reflected (the diffuse component). In this portion of the equation, the ambient intensity component is dependent upon the ambient light intensity Ia, while the diffuse component is dependent upon the intensity Ii of a particular light source. The term ks(Rxc2x7V)n is the specularly reflected light intensity component, which is also dependent upon the light source intensity Ii.
In the equation, ka, kd and ks are the ambient, diffuse and specular reflection constants. The value of these constants depends upon a number of factors, such as the texture of the surface which is being modeled or imaged.
L is the light vector, V is the viewing vector and R is the reflection vector. One arrangement of the inter-relationship of the L, V and R vectors is illustrated in FIG. 2. In accordance with this light intensity equation, the dot product of the vectors R and V (i.e. Rxc2x7V) represents the cosine of the angle between the two vectors. The R vector may be calculated in accordance with the equation R=2*(Nxc2x7L)*Nxe2x88x92L. Likewise, the dot product of the vectors L and N (i.e. Lxc2x7N) represents the cosine of the angle between these two vectors.
In accordance with the Gouraud method, once the intensity of the light is calculated at each vertex of the polygon, the intensity of the light is then linearly interpolated to each other point on the polygon (each point corresponding to a display pixel). For example, referring again to FIG. 1, the light intensity I4 at a point P4 along a scan line SL is interpolated by first interpolating the light intensities I5 and I6 at the intersection of the scan line with the polygon edges at points P5 and P6. The intensities I5 and I6 are interpolated from the intensities I1 and I3, and I2 and I3 at the vertices, respectively. The intensity I4 is then interpolated from the light intensities I5 and I6.
This method is discussed in Gouraud, xe2x80x9cContinuous Display of Curved Surfaces,xe2x80x9d Ph. D. dissertation, Department of Computer Science, University of Utah, Salt Lake City, June 1971. This method is also discussed generally in xe2x80x9cFundamentals of Interactive Computer Graphicsxe2x80x9d by Foley, Van Dam and Addison-Wesley, 1984.
This method of calculating the specularly reflected light component has several problems. A first problem is that if no specular reflection component is present at a vertex of the polygon, then no specular reflection component will be yielded anywhere in that portion of the image derived from that polygon. This is the case since the specular component at all non-vertex points of the polygon are interpolated from the specular component at the vertices. In addition, this method may result in exaggerated intensity changes at discontinuities. As a result, the imaged object may not appear as the actual object would appear.
Another problem with this method is that the specular component is based upon the dot product of the R and V vectors. In other words, the specular component is based upon the cosine of the angle between these vectors. As is well known, the cosine function changes little at angles near 0 degrees. On the other hand, specular reflection only occurs at angles near 0 degrees. So that the specular function transitions smoothly from angles near 0 degrees to larger angles where no reflection is visible, the differences in the cosine values at these angles must be exaggerated. This can be accomplished by raising the cosine value by a power n. On the other hand, this makes the computation more demanding, and increases the error associated with calculation of the specular component.
Another method of modeling or calculating the specular reflection is known as the Phong method. In accordance with this method, a normal vector is calculated at each vertex of the polygon. The normal vector at other points of the polygon are interpolated from these vertex normals. The normal vector at a particular point or pixel is then normalized, i.e. turned into a unit vector, and the resulting normalized vector is used in the above-referenced light intensity calculation.
In the example illustrated in FIG. 1, the Phong method requires the calculation of the normal vectors N5 and N6 at points P5 and P6, as interpolated from the normal vectors at points N1 and N3, and N2 and N3, respectively. Then, the normal vector N4 at point P4 is calculated from the normal vectors N5 and N6. This normal vector N4 is then normalized (i.e. converted to a unit vector) for use in the light intensity calculation.
This method is discussed in Foley, Van Dam and Addison-Wesley, supra, and in Phong, xe2x80x9cIllumination of Computer-Generated Images,xe2x80x9d Ph.D. dissertation, Department of Electrical Engineering, University of Utah, July 1973.
There are several problems with the Phong method. First, the normal vector must be calculated at each point or pixel. In addition, this normal vector must be converted to a unit vector. The transformation of the normal vector into a unit normal vector requires the calculation of the reciprocal square root of the terms of the vector. These calculations are very demanding in terms of computational effort and time. In addition, the dot product of the R and V vectors must still be raised to an arbitrary power n. That this calculation must be done at each point or pixel also increases the calculation demands. As a result, the Phong method is more interesting from a theoretical perspective than actually useful when considering the computational demands of the method.
A problem associated with use of either of the above-identified models is that the calculation of the specular reflection component requires calculation of the reflection vector R. Because the reflection vector R may change at each point of a surface, the above-equations require the reflection vector R to be re-calculated at each individual point or pixel. Once again, this arrangement is computationally demanding.
As one attempt to overcome some of the above-stated problems, in the Blinn method of modeling specular highlights, the need for calculating the reflection vector R is eliminated by use of a vector H called the halfway vector. In accordance with this model, the value Rxc2x7V is replaced with Nxc2x7H, where H is a vector extending from the point halfway between the N and V vectors, i.e. H=(L+V)/2. The value Nxc2x7H represents the cosine of the angle xcex3, as illustrated in FIG. 2. This method is discussed in Blinn, xe2x80x9cModels of Light Reflection For Computer Synthesized Pictures,xe2x80x9d SIGGRAPH Proceedings, pages 192-198, July 1977.
When this improvement is applied to the Gouraud shading model, however, the problems associated with light intensity interpolation still exist. If this improvement is applied to the Phong model, the specular component computation is still demanding since the reciprocal square root calculation is still required to normalize the normal vector at the point or pixel under consideration.
A further attempt to provide a less computationally demanding specular reflectivity model exists in which individual calculations of the intensities are avoided by using a second-degree Taylor expansion to approximate Phong shading data. This method is discussed in Bishop and Weiner, xe2x80x9cFast Phong Shading,xe2x80x9d ACM Vol. 20, No. 4, July 1986, pages 103-106.
This method is still substantially more complex than Gouraud shading, and yet introduces additional approximations as compared to the Phong method.
The invention is a method and apparatus for modeling the specular reflection of light from a surface of an object to be graphically imaged.
In accordance with one embodiment of a method of the invention, a portion of the object to be imaged is modeled with one or more surfaces. In one or more embodiments, the surface comprises a quadratic triangular Bezier surface having three vertices and three edge midpoints.
A sine value associated with a highlight angle is determined. In at least one embodiment, the sine value comprises the sine squared value of the angle between a normal vector and a halfway vector at each vertex and edge midpoint. A control value is determined at each vertex and edge midpoint based on the sine values.
A specular input value at one or more other points on the surface is determined from the control values. In one or more embodiments, the specular input value is dependent upon the barycentric coordinates of the particular point in relation to the vertices and edge midpoints. The specular input value at each point is utilized to determine the specular reflection component of light at each point.
In one or more embodiments, the specular input component at each point is reparametrized to fall within the range of 1 to 0 before being used to calculate the specular reflection component. In at least one embodiment, the reparametrization is accomplished with a cubic spline function.
In one or more embodiments, the specular component at each point is added to an ambient light component and a diffuse light component to generate a combined light data component for that point.
In one or more embodiments, computer hardware is arranged to perform the method of the invention.
Further objects, features, and advantages of the present invention over the prior art will become apparent from the detailed description of the drawings which follows, when considered with the attached figures.